package com.todoclipse.api;

import java.awt.Color;
import java.util.Set;

public class ProjectItem extends AbstractItem implements Comparable<ProjectItem> {

	private String name;
	private Color color;
	private int cacheCount; // liczba taskow?
	private Set<ProjectItem> subprojects;

	public ProjectItem(long id, long userId, String name) {
		super(id,userId);
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if (name == null) {
			throw new NullPointerException("Name cannot be null!");
		}
		this.name = name;
	}

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	public int getCacheCount() {
		return cacheCount;
	}

	public void setCacheCount(int cacheCount) {
		this.cacheCount = cacheCount;
	}

	public Set<ProjectItem> getSubprojects() {
		return subprojects;
	}

	public void setSubprojects(Set<ProjectItem> subprojects) {
		this.subprojects = subprojects;
	}

	public int compareTo(ProjectItem o) {
		return this.name.compareTo(o.name);
	}

	@Override
	public boolean equals(Object obj) {
		boolean result = (this == obj);
		if (result == false && obj instanceof ProjectItem) {
			ProjectItem p = (ProjectItem) obj;
			result = this.name.equals(p.name);
		}
		return result;
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}
	
	@Override
	public String toString() {
		return name;
	}
}
